<template>
	<z-paging ref="paging" v-model="dataList" @query="query" hide-empty-view>
		<view class="posterPage">
			<view class="content1">
				<u-text text="11月1日-11月11日" bold align="center" color="#8C2743" size="24rpx" />
				<view class="content1_tips">
					<view class="content1_tips_item">
						<u-text text="一站式绿通限量送" color="#8C2743" size="20rpx" align="center"
							iconStyle="margin-right:6rpx;width:22rpx;height:22rpx"
							prefixIcon="https://oneredhealth.oss-cn-hangzhou.aliyuncs.com/2023/10/25/b94bee873ddd4b0bbb2789c6bb6a46a5.png" />
					</view>
					<view class="content1_tips_item">
						<u-text text="3333元红包送送送" color="#8C2743" size="20rpx" align="center"
							iconStyle="margin-right:6rpx;width:22rpx;height:22rpx"
							prefixIcon="https://oneredhealth.oss-cn-hangzhou.aliyuncs.com/2023/10/25/8e7b315148724768b99eebc2cd72f45c.png" />
					</view>
					<view class="content1_tips_item">
						<u-text text="双十一满再送" color="#8C2743" size="20rpx" align="center"
							iconStyle="margin-right:6rpx;width:22rpx;height:22rpx"
							prefixIcon="https://oneredhealth.oss-cn-hangzhou.aliyuncs.com/2023/10/25/75580558d1f34e2395174530f7310c88.png" />
					</view>

				</view>
				<view class="content1_notice">
					<u-text text="先领券 后购买（每天都可领~)" color="#8C2743" size="28rpx" bold align="left"
						iconStyle="margin-right:30rpx;width:48rpx;height:48rpx"
						prefixIcon="https://oneredhealth.oss-cn-hangzhou.aliyuncs.com/2023/10/25/0d68df88824342c6ac22a80e69a5f202.png" />
				</view>
			</view>

			<view class="content2">
				<view class="content2_center">
					<view class="content2_center_button">
						<u-button text="立即去抢" shape="circle" size="large" :customStyle="buttonCustomStyle"
							:hairline="false" v-if="leftCount >= 1" @click="getCardHandler" />
						<u-button text="今日已抢空" shape="circle" size="large" v-else
							:customStyle="{...buttonCustomStyle,...buttonCustomStyle2}" :hairline="false" />
						<image class="content2_center_button_pointer"
							src="https://oneredhealth.oss-cn-hangzhou.aliyuncs.com/2023/10/25/98c3b1bbcbd243049b23fc05dbace199.png"
							mode="aspectFit" v-if="leftCount >= 1" />
						<u-text text="每天限量10份，抢完即止" bold align="center" color="#FFFFFF" size="28rpx"
							margin="20rpx 0 0" />
					</view>
				</view>
			</view>

			<view class="content3">
				<view class="content3_text">
					<text style="color: #FE3E2F;">3333 元、1111 元红包每天送 <text
							style="color: #3D3D3D;">，每天可领取一个，购买时可以对应相应产品直接抵扣。</text></text>
				</view>
				<view class="content3_couponFirst" @click="toDetail(dataList[0].id)">
					<view class="content3_couponFirst_left">
						<view style="display: flex;align-items: baseline;">
							<text style="font-size: 36rpx;color: #FC1F34;font-weight: bold;">¥</text>
							<view>
								<u-text :text="dataList[0].favorableFaceValue || 0" mode="money" size="64rpx"
									color="#FC1F34" bold align="center" />
							</view>
						</view>
					</view>
					<view class="content3_couponFirst_center">
						<u-text text="*购买时可以对应相应产品现金抵扣" mode="money" size="24rpx" color="#3D3D3D" align="center" />
					</view>
					<view class="content3_couponFirst_right" @click.stop="collectionHandler(dataList[0].id)">
						<u-button :text="dataList[0].status ? '立即领取' : dataList[0].statusText" :hairline="false"
							:customStyle="dataList[0].status?buttonCustomStyle3:buttonCustomStyleDisable"
							shape="circle" />
					</view>
				</view>
				<view class="content3_couponList">
					<view class="content3_couponList_couponItem"
						v-for="couponItem in dataList.filter((item,index)=>index !== 0)" :key="couponItem.id">
						<view class="content3_couponList_couponItem_top" @click="toDetail(couponItem.id)">
							<view class="content3_couponList_couponItem_top_content">
								<view class="content3_couponList_couponItem_top_content_topLeft">部分商品</view>
								<view
									style="display: flex;align-items: baseline;justify-content: center;margin-top: 12rpx;">
									<text style="font-size: 28rpx;color: #FC1F34;font-weight: bold;">¥</text>
									<view>
										<u-text :text="couponItem.favorableFaceValue || $el" mode="money" size="50rpx"
											color="#FC1F34" bold align="center" />
									</view>
								</view>
							</view>
						</view>
						<view class="content3_couponList_couponItem_bottom">
							<u-button :text="couponItem.status?'立即领取':couponItem.statusText"
								:customStyle="buttonCustomMini"
								:color="couponItem.status ? 'linear-gradient(270deg, #33393E 0%, #323A3C 100%)': 'linear-gradient(270deg, #B1B1B1 0%, #8C8C8C 100%)' "
								:hairline="false" shape="circle" @click="collectionHandler(couponItem.id)" />
						</view>
					</view>
				</view>
				<view style="width: 658rpx;margin: 0 auto;margin-top: 116rpx;">
					<u-text text="*具体可使用产品请点击查看" size="24rpx" color="#FC1F34" align="left" />
				</view>
			</view>
			<view class="content4">
				<view class="content4_item">
					<view class="content4_item_top">实际消费¥1000</view>
					<image class="content4_item_image"
						src="https://oneredhealth.oss-cn-hangzhou.aliyuncs.com/2023/10/26/dc3eaca7496f42d9818d9d0ec9d37252.png"
						mode="aspectFit"></image>
					<view class="content4_item_bottom">
						<u-text text="再送110元维C礼盒一盒" color="#DD4100" size="16rpx" align="center" />
						<u-text text="(共6只)" color="#DD4100" size="16rpx" align="center" />
					</view>
				</view>

				<view class="content4_item">
					<view class="content4_item_top">实际消费¥3000</view>
					<image class="content4_item_image"
						src="https://oneredhealth.oss-cn-hangzhou.aliyuncs.com/2023/10/26/7710bf87efa94f6c8a77d56264a3c02d.png"
						mode="aspectFit"></image>
					<view class="content4_item_bottom">
						<u-text text="再送398元益生菌一盒" color="#DD4100" size="16rpx" align="center" />
					</view>
				</view>

				<view class="content4_item">
					<view class="content4_item_top">实际消费¥5000</view>
					<image class="content4_item_image"
						src="https://oneredhealth.oss-cn-hangzhou.aliyuncs.com/2023/10/26/8c332da85f304f5cbf808a5ba90c3d60.png"
						mode="aspectFit"></image>
					<view class="content4_item_bottom">
						<u-text text="再送828元送肠癌早筛一个" color="#DD4100" size="14rpx" align="center" />
					</view>
				</view>
			</view>
			<view class="footerTips">
				<u-text text="*以上活动信息，如有不明之处可咨询健康管家" color="#FFF" size="24rpx" align="left" />
			</view>
			<view class="concatQRCode">
				<u-icon label="健康管家-郑医生" labelPos="bottom" width="232rpx" height="232rpx"
					name="https://oneredhealth.oss-cn-hangzhou.aliyuncs.com/2023/10/26/228bc5ff3b63406eacaaa2aa756b8457.png"
					labelColor="#FFCF06" space="48rpx" labelSize="24rpx"
					@click="previewImage('https://oneredhealth.oss-cn-hangzhou.aliyuncs.com/2023/10/26/228bc5ff3b63406eacaaa2aa756b8457.png')" />
				<u-icon label="【十蜂健康】公众号" labelPos="bottom" width="232rpx" height="232rpx"
					name="https://oneredhealth.oss-cn-hangzhou.aliyuncs.com/2023/10/26/6914c2bfd5d240f9ac561e581c97fbf1.png"
					labelColor="#FFCF06" space="48rpx" labelSize="24rpx"
					@click="previewImage('https://oneredhealth.oss-cn-hangzhou.aliyuncs.com/2023/10/26/6914c2bfd5d240f9ac561e581c97fbf1.png')" />
			</view>
		</view>
	</z-paging>
</template>

<script>
	import {
		getCouponList,
		checkCouponStatus,
		collectionCoupon,
		getActivityList,
		reciveCard
	} from '@/api/activity.js'
	export default {
		data() {
			return {
				dataList: [],
				activityList: [],
				leftCount: 0,
				buttonCustomStyle: {
					width: '100%',
					height: '100%',
					background: "url(https://oneredhealth.oss-cn-hangzhou.aliyuncs.com/2023/10/25/c2e574f6d5024a239b682d007ebec95b.png) no-repeat",
					backgroundSize: "cover",
					backgroundPosition: "center",
					padding: 0,
					border: "none",
					color: "#FFF",
					fontSize: "48rpx"
				},
				buttonCustomStyle2: {
					background: "url(https://oneredhealth.oss-cn-hangzhou.aliyuncs.com/2023/10/25/be7043931c9841918602d3104e53b01f.png) no-repeat",
				},
				buttonCustomStyle3: {
					width: '142rpx',
					height: "66rpx",
					background: "linear-gradient(270deg, #FA343E 0%, #F57953 100%)",
					boxShadow: "0rpx 2rpx 0rpx 0rpx #C52003",
					border: "none",
					color: "#FFF",
					padding: 0
				},
				buttonCustomStyleDisable: {
					width: '142rpx',
					height: "66rpx",
					border: "none",
					color: "#FFF",
					padding: 0,
					background: "linear-gradient(270deg, #B1B1B1 0%, #CCCCCC 100%)",
					boxShadow: "none",
				},
				buttonCustomMini: {
					width: '144rpx',
					height: '34rpx',
				},
			}
		},
		methods: {
			getCardHandler() {
				uni.$u.route({
					url: '/pages_receive/receive_detail/index',
					params: {
						scene: this.activityList[0].orderNum
					}
				})
			},
			async collectionHandler(id) {
				const result = await collectionCoupon(id)
				this.$refs.paging.refresh()
			},
			async query() {
				// 权益卡
				const activityList = await getActivityList('双十一')
				this.activityList = activityList.data
				reciveCard({
					orderNum: this.activityList[0].orderNum,
					wantNum: 1,
				}).then(res => {
					this.leftCount = res.data
				})
				// 优惠券
				const listResult = await getCouponList({
					activityName: "双十一"
				})
				const couponList = listResult.data.rows.map(item => {
					const newItem = {
						...item,
						favorableFaceValue: item.favorableFaceValue / 100,
						status: false,
						statusText: ''
					}
					checkCouponStatus(item.id).then(statusResult => {
						newItem.statusText = statusResult.data
						if (statusResult.data === '立即领取') {
							newItem.status = true
						} else {
							newItem.status = false
						}
					})
					return newItem
				})
				this.$refs.paging.completeByNoMore(couponList, false)
			},
			previewImage(current) {
				uni.previewImage({
					urls: [
						"https://oneredhealth.oss-cn-hangzhou.aliyuncs.com/2023/10/26/228bc5ff3b63406eacaaa2aa756b8457.png",
						"https://oneredhealth.oss-cn-hangzhou.aliyuncs.com/2023/10/26/6914c2bfd5d240f9ac561e581c97fbf1.png"
					],
					current,
					indicator: 'default',
					loop: false,
				});
			},
			toDetail(id) {
				uni.$u.route({
					url: '/pages_activity/coupon/index',
					params: {
						id
					}
				})
			}
		}
	}
</script>

<style>
	page {
		background: #1784F5;
	}
</style>

<style lang="scss" scoped>
	.posterPage {
		width: 100vw;
		height: 3866rpx;
		background: url("https://oneredhealth.oss-cn-hangzhou.aliyuncs.com/2023/10/25/78679c4751c544f1896ee81a7dc9d4d4.png") no-repeat;
		background-size: 100%;
		background-position: top;
		padding: 0 11rpx;
		box-sizing: border-box;
		overflow: hidden;

		.footerTips {
			width: 714rpx;
			margin: 40rpx auto 0;
		}

		.concatQRCode {
			width: '100%';
			display: flex;
			justify-content: space-between;
			padding: 68rpx 88rpx 0;
			box-sizing: border-box;
		}

		.content4 {
			width: 714rpx;
			height: 490rpx;
			margin: 0 auto;
			display: flex;
			padding: 156rpx 36rpx 0;
			box-sizing: border-box;
			justify-content: space-between;
			background: url("https://oneredhealth.oss-cn-hangzhou.aliyuncs.com/2023/10/26/4519df51aecb4da39ac6a1f937fbab3f.png") no-repeat;
			background-size: 100%;

			&_item {
				width: 204rpx;
				height: 292rpx;
				border-radius: 24rpx;
				border: 1px solid #FFF;
				background: #E6F5FF;
				position: relative;
				padding: 10rpx;
				box-sizing: border-box;
				display: flex;
				flex-direction: column;
				justify-content: center;

				&_top {
					width: 172rpx;
					height: 40rpx;
					border: 1px solid #FFF;
					border-bottom-left-radius: 30rpx;
					border-bottom-right-radius: 30rpx;
					background: linear-gradient(180deg, #FEBE59 14%, #FF804F 97%);
					margin: 0 auto;
					position: absolute;
					top: 0;
					left: 0;
					right: 0;
					font-size: 18rpx;
					display: flex;
					align-items: center;
					justify-content: center;
					color: #FFF
				}

				&_image {
					width: 184rpx;
					height: 214rpx;
				}

				&_bottom {
					height: 40rpx;
					display: flex;
					flex-direction: column;
					align-items: center;
					justify-content: center;
					margin-top: 20rpx;
				}
			}
		}

		.content3 {
			width: 714rpx;
			height: 650rpx;
			background: url("https://oneredhealth.oss-cn-hangzhou.aliyuncs.com/2023/10/25/bb32a3210b5742c7955873cb0666793f.png") no-repeat;
			background-size: 100%;
			margin: 0 auto;
			overflow: hidden;

			&_text {
				font-size: 24rpx;
				padding: 148rpx 44rpx 0;
				box-sizing: border-box;
			}

			&_couponList {
				width: 658rpx;
				height: auto;
				display: flex;
				justify-content: space-between;
				margin: 70rpx auto 0;

				&_couponItem {
					width: 214rpx;
					position: relative;

					&_top {
						width: 206rpx;
						height: 80rpx;
						border: 1px solid #21EFF5;
						border-radius: 20rpx;
						background-color: #E6FFFF;
						position: absolute;
						left: 0;
						top: 0;
						right: 0;
						bottom: 0;
						margin: auto;
						z-index: 2;

						&_content {
							width: 100%;
							height: 100%;
							position: relative;
							overflow: hidden;

							&_topLeft {
								display: flex;
								align-items: center;
								justify-content: center;
								position: absolute;
								left: 0;
								top: 0;
								border-top-left-radius: 20rpx;
								border-bottom-right-radius: 20rpx;
								font-size: 18rpx;
								width: 100rpx;
								height: 26rpx;
								color: #FFF;
								background: linear-gradient(180deg, #F66166 0%, #FF456D 100%);
							}
						}
					}

					&_bottom {
						width: 214rpx;
						height: 80rpx;
						border-radius: 20rpx;
						background: linear-gradient(125deg, #23FEED 0%, #1EC3FF 100%);
						position: absolute;
						left: 0;
						top: 0;
						right: 0;
						bottom: -100rpx;
						margin: auto;
						z-index: 1;
						padding-top: 38rpx;

						::v-deep.u-button__text {
							font-size: 24rpx !important;
						}
					}
				}
			}

			&_couponFirst {
				width: 658rpx;
				height: 136rpx;
				background: url("https://oneredhealth.oss-cn-hangzhou.aliyuncs.com/2023/10/25/9a440dcba3774bd58d86dd59ca94fef0.png") no-repeat;
				background-size: 100%;
				margin: 40rpx auto 0;
				display: flex;
				align-items: center;

				&_left {
					width: 200rpx;
					height: 118rpx;
					margin-left: 8rpx;
					display: flex;
					align-items: center;
					justify-content: center;
				}

				&_center {
					width: 252rpx;
					height: 118rpx;
					display: flex;
					align-items: center;
					padding: 0 14rpx;
				}

				&_right {
					width: 190rpx;
					height: 118rpx;
					display: flex;
					align-items: center;

					::v-deep.u-button__text {
						font-size: 28rpx !important;
						font-weight: bold;
					}
				}
			}
		}

		.content2 {
			width: 714rpx;
			height: 782rpx;
			background: url("https://oneredhealth.oss-cn-hangzhou.aliyuncs.com/2023/10/25/ab6ab41f8b294accb80c4f3e0d7475ce.png") no-repeat;
			background-size: 100%;
			padding: 190rpx 0 58rpx;
			box-sizing: border-box;
			margin: 0 auto;

			&_center {
				width: 656rpx;
				height: 510rpx;
				background: url("https://oneredhealth.oss-cn-hangzhou.aliyuncs.com/2023/10/25/a66543b8ab574d27a1f40cbe86843c10.png") no-repeat;
				background-size: 100%;
				margin: 0 auto;
				overflow: hidden;

				&_button {
					width: 506rpx;
					height: 108rpx;
					margin: 310rpx auto 0;
					position: relative;

					&_pointer {
						position: absolute;
						right: -10rpx;
						top: 40rpx;
						width: 108rpx;
						height: 108rpx;
					}

					::v-deep.u-button__text {
						font-size: 48rpx !important;
						font-weight: bold;
					}
				}
			}
		}

		.content1 {
			width: 714rpx;
			height: 470rpx;
			background: url("https://oneredhealth.oss-cn-hangzhou.aliyuncs.com/2023/10/25/148d9a02361740628f5af14e0396e4d4.png") no-repeat;
			background-size: 100%;
			margin: 0 auto;
			margin-top: 908rpx;
			padding-top: 172rpx;

			&_tips {
				width: 100%;
				padding: 0 40rpx;
				box-sizing: border-box;
				display: flex;
				justify-content: space-between;
				margin-top: 48rpx;

				&_item {
					width: auto;
					height: 48rpx;
					border-radius: 18rpx;
					background-color: #FFF;
					display: flex;
					align-items: center;
					padding: 0 14rpx;
					justify-content: space-between;
					box-sizing: border-box;
				}
			}

			&_notice {
				width: 100%;
				padding: 0 50rpx;
				box-sizing: border-box;
				margin-top: 56rpx;
			}
		}
	}
</style>